********************************************************************************
* Supplemental appendix file: "Creating crowny capitalists"
* June 24, 2019
* Contact: bernhard.reinsberg@glasgow.ac.uk
********************************************************************************

***********************************************************************
* Main TSCS analysis - supplemental appendix
***********************************************************************

* Data 

  use "Replication_MAIN", clear
  
  replace vdem_corr=100*vdem_corr
  replace vdem_pubcorr=100*vdem_pubcorr
  replace vdem_execorr=100*vdem_execorr 
  
  drop if incid==1
  g lngdppc=ln(gdppc_WDI)
  g lnpop=ln(unna_pop)
  g lnoilpc=ln(1+ross_oil_prod_QOG/unna_pop)
  g oilpc=ross_oil_prod_QOG/unna_pop
  g HRV_index=transparencyindex
  g ssa=(regid==7)
  g lic=(incid==2)

  sort cid year 
  xtset cid year  
  
  g IMFcum=.
  g Loancum=.
  forvalues i=1980/2014{
    g imf=IMFnn
	replace imf=. if year>`i' | year<=`i'-5
	egen IMF=sum(imf), by(cid)
	replace IMFcum=IMF if year==`i'
	drop imf IMF 
	
	g ploan=loan
	replace ploan=. if year>`i' | year<=`i'-5
	egen PLOAN=sum(ploan), by(cid)
	replace Loancum=ln(1+PLOAN) if year==`i'
	drop ploan PLOAN 
  }
  lab var IMFcum "Past programs"
  lab var Loancum "Prior use of IMF credit, logarithmized"

  global BMAmax  lngdppc p_durable_QOG p_polity2_QOG  pop_urb_tot_WDI min_gdp_WDI lnoilpc
  global LBMAmax  L.lngdppc L.p_durable_QOG L.p_polity2_QOG  L.pop_urb_tot_WDI L.min_gdp_WDI L.lnoilpc

  global BMAmin  lngdppc pwt_hci_QOG p_durable_QOG p_polity2_QOG pop_urb_tot_WDI gxp_gdp_WDI min_gdp_WDI lnoilpc 
  global LBMAmin  L.lngdppc L.pwt_hci_QOG L.p_durable_QOG L.p_polity2_QOG L.pop_urb_tot_WDI L.gxp_gdp_WDI L.min_gdp_WDI L.lnoilpc

  qui xi:reg icrgPC i.cid i.year i.regid
  set matsize 2000
  cmp setup 

  
* Descriptive statistics 

  qui estpost summarize icrgPC IMFnn SCB QCB $BMAmin 
  
  ** Table A2 - ICRG sample **
  esttab, cells("count mean sd min max") noobs replace
  
  * qui estpost summarize icrgPC vdem_corr vdem_pubcorr vdem_execorr vdem_gcrrpt vdem_jucorrdc  vdem_excrptps vdem_exbribe vdem_exembez  ti_cpi icc_WGI  wdi_tacpsr gcb_*
  * esttab, cells("count mean sd min max") noobs replace 
  * last VDEMs are ordinal with 0=always .. 4=never 
  
  
* Table B1: Fewer controls

  mat LIV1=J(6,5,0) 
  mat LIV1Diag=J(3,5,0)

forvalues l=1/5{
  
  local k=`l'+1
  di "ICRG index, lag=`l'"
  
  global X L`l'.lngdppc L`l'.p_durable_QOG L`l'.p_polity2_QOG  L`l'.pop_urb_tot_WDI L`l'.min_gdp_WDI L`l'.lnoilpc
  global Z L`k'.IMFcum L`k'.s_unga3g7 L`k'.nUnder L`k'.lngdppc L`k'.p_polity2_QOG L`k'.reserves L`k'.gdp_growth_WDI L`k'.debtser_gni L`k'.dpi_exelec _Iregid* _Iyear*
  
  qui egen var2=mean(SCB), by(cid)
  qui gen int2=var2*L`l'.nUnder
  qui egen var3=mean(QCB), by(cid)
  qui gen int3=var3*L`l'.nUnder
  
  qui cmp (icrgPC =L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Icid* _Iyear*) (L`l'.SCB =int2 $X _Icid* _Iyear*) (L`l'.QCB=int3 $X _Icid* _Iyear*) (L`l'.IMFnn=$Z), indicators($cmp_cont $cmp_cont $cmp_cont $cmp_probit) ro cl(cid) iterate(50)
  est store sqeff`l'
  mat B=e(b)
  mat S=e(V)
  mat LIV1[1,`l']=B[1,1]
  mat LIV1[2,`l']=sqrt(S[1,1])
  mat LIV1[3,`l']=B[1,2]
  mat LIV1[4,`l']=sqrt(S[2,2])
  mat LIV1[5,`l']=B[1,3]
  mat LIV1[6,`l']=sqrt(S[3,3])
  qui test ([L`l'SCB]int2 [L`l'QCB]int3)
  mat LIV1Diag[3,`l']=r(chi2)
  qui xtreg icrgPC int2 int3 L`l'.IMFnn $X _Iyear* if e(sample), fe 
  mat LIV1Diag[2,`l']=e(r2_w)	
  mat LIV1Diag[1,`l']=e(N)
  
  drop var* int*
  }
  
  ** Table B1 **
  mat li LIV1
  mat li LIV1Diag 

  estout sqeff*, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_w N F, fmt(%7.2f %7.0f %7.2f)) keep(*IMFnn *SCB *QCB)
  
  
* Table B2: Conditional marginal effects 

  mat Diag=J(3,6,0)
  local m=1

  foreach mod in milexp pop_urb totnontax{
  
    qui su `mod', d
	g mod50=(`mod'>`r(p50)')
  
  local l=4
  local k=`l'+1
  di "ICRG index, lag=`l'"
  
  global X L`l'.lngdppc L`l'.pwt_hci_QOG L`l'.p_durable_QOG L`l'.p_polity2_QOG L`l'.pop_urb_tot_WDI L`l'.gxp_gdp_WDI L`l'.min_gdp_WDI L`l'.lnoilpc
  global Z L`k'.IMFcum L`k'.s_unga3g7 L`k'.nUnder L`k'.lngdppc L`k'.p_polity2_QOG L`k'.reserves L`k'.gdp_growth_WDI L`k'.debtser_gni L`k'.dpi_exelec _Iregid* _Iyear*
  
  qui egen var2=mean(SCB), by(cid)
  qui gen int2=var2*L`l'.nUnder
  qui egen var3=mean(QCB), by(cid)
  qui gen int3=var3*L`l'.nUnder

  ** mod==0  
  qui cmp (icrgPC =L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Icid* _Iyear*) (L`l'.SCB =int2 $X _Icid* _Iyear*) (L`l'.QCB=int3 $X _Icid* _Iyear*) (L`l'.IMFnn=$Z) if mod50==0, indicators($cmp_cont $cmp_cont $cmp_cont $cmp_probit) ro cl(cid) iterate(70)
  est store mod0`mod'
  qui test ([L`l'SCB]int2 [L`l'QCB]int3)
  mat Diag[3,2*`m'-1]=r(chi2)
  qui xtreg icrgPC int2 int3 L`l'.IMFnn $X _Iyear* if e(sample), fe 
  mat Diag[1,2*`m'-1]=e(N)
  mat Diag[2,2*`m'-1]=e(r2_w)
  
  ** mod==1
  qui cmp (icrgPC =L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Icid* _Iyear*) (L`l'.SCB =int2 $X _Icid* _Iyear*) (L`l'.QCB=int3 $X _Icid* _Iyear*) (L`l'.IMFnn=$Z) if mod50==1, indicators($cmp_cont $cmp_cont $cmp_cont $cmp_probit) ro cl(cid) iterate(70)
  est store mod1`mod'
  qui test ([L`l'SCB]int2 [L`l'QCB]int3)
  mat Diag[3,2*`m']=r(chi2)
  qui xtreg icrgPC int2 int3 L`l'.IMFnn $X _Iyear* if e(sample), fe 
  mat Diag[1,2*`m']=e(N)
  mat Diag[2,2*`m']=e(r2_w)
  
  drop var* int* mod50
  local m=`m'+1
}
  estout *milexp, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_w N F, fmt(%7.2f %7.0f %7.2f)) keep(*IMFnn *SCB *QCB)
  estout *pop_urb, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_w N F, fmt(%7.2f %7.0f %7.2f)) keep(*IMFnn *SCB *QCB)
  estout *totnontax, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_w N F, fmt(%7.2f %7.0f %7.2f)) keep(*IMFnn *SCB *QCB)
  mat li Diag
  
  
  
* Table B3: Loan size in first stage
 
  mat LIVl=J(6,5,0)
  mat LIVlDiag=J(3,5,0)

forvalues l=1/5{
  
  local k=`l'+1
  di "ICRG index, lag=`l'"
  
  global X L`l'.lngdppc L`l'.pwt_hci_QOG L`l'.p_durable_QOG L`l'.p_polity2_QOG L`l'.pop_urb_tot_WDI L`l'.gxp_gdp_WDI L`l'.min_gdp_WDI L`l'.lnoilpc
  global Z L`k'.Loancum L`k'.s_unga3g7 L`k'.nUnder L`k'.lngdppc L`k'.p_polity2_QOG L`k'.reserves L`k'.gdp_growth_WDI L`k'.debtser_gni L`k'.dpi_exelec _Iregid* _Iyear*
  
  qui egen var2=mean(SCB), by(cid)
  qui egen var3=mean(QCB), by(cid)
  qui g int2=var2*l`l'.nUnder
  qui g int3=var3*l`l'.nUnder
  
  qui cmp (icrgPC =L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Icid* _Iyear*) (L`l'.SCB=int2 $X _Icid* _Iyear*) (L`l'.QCB=int3 $X _Icid* _Iyear*) (L`l'.IMFnn=$Z), indicators($cmp_cont $cmp_cont $cmp_cont $cmp_probit) ro cl(cid) iterate(100)
  est store rl_sqeff`l'
  mat B=e(b)
  mat S=e(V)
  mat LIVl[1,`l']=B[1,1]
  mat LIVl[2,`l']=sqrt(S[1,1])
  mat LIVl[3,`l']=B[1,2]
  mat LIVl[4,`l']=sqrt(S[2,2])
  mat LIVl[5,`l']=B[1,3]
  mat LIVl[6,`l']=sqrt(S[3,3])
  qui test ([L`l'SCB]int2 [L`l'QCB]int3)
  mat LIVlDiag[3,`l']=r(chi2)
  qui xtreg icrgPC L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Iyear* if e(sample), fe 
  mat LIVlDiag[2,`l']=e(r2_w)	
  mat LIVlDiag[1,`l']=e(N)	
  drop var* int2 int3
  }
  
  ** Table B3 **
  mat li LIVl
  mat li LIVlDiag
  
  estout rl_sqeff*, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_w N F, fmt(%7.2f %7.0f %7.2f)) keep(*IMFnn *SCB *QCB)
  

* Table B4: Extreme Bounds Analysis --> R-file available upon request
  

* Subsequent tables: Alternative indicators of corruption

foreach y in vdem_corr vdem_execorr ti_cpi icc_WGI{

  di "outcome `y'"
  mat D`y'=J(3,5,0)

  forvalues l=1/5{
  
  di " ... lag `l'"
  global X L`l'.lngdppc L`l'.pwt_hci_QOG L`l'.p_durable_QOG L`l'.p_polity2_QOG L`l'.pop_urb_tot_WDI L`l'.gxp_gdp_WDI L`l'.min_gdp_WDI L`l'.lnoilpc
  
  qui xtreg `y' L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Iyear*, fe cl(cid)
  est store fe`y'`l'
  mat D`y'[1,`l']=e(N)
  mat D`y'[2,`l']=e(r2_w)

  qui egen meanIMF=mean(IMFnn), by(cid)
  g lnunder=nUnder
  qui g ivIMF=lnunder*meanIMF
  global Z L`l'.ivIMF L`l'.lnunder L`l'.meanIMF _Icid* _Iyear* 
  global Z0 L`k'.IMFcum L`k'.s_unga3g7 L`k'.nUnder L`k'.lngdppc L`k'.p_polity2_QOG L`k'.reserves L`k'.gdp_growth_WDI L`k'.debtser_gni L`k'.dpi_exelec _Iregid* _Iyear*

  qui cmp (`y'=L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Iyear* _Icid*) (L`l'.IMFnn=$Z0), indicators($cmp_cont $cmp_probit) ro cl(cid) iterate(50)
  est store s`y'`l'

  qui egen meanSCB=mean(SCB), by(cid)
  qui egen meanQCB=mean(QCB), by(cid)
  qui g ivSCB=meanSCB*lnunder
  qui g ivQCB=meanQCB*lnunder 
  global VS L`l'.ivSCB L`l'.lnunder L`l'.meanSCB _Icid* _Iyear*  
  global VQ L`l'.ivQCB L`l'.lnunder L`l'.meanQCB _Icid* _Iyear* 
  
  qui cmp (`y'=L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Iyear* _Icid*) (L`l'.IMFnn=$Z0) (L`l'.SCB=$VS $X) (L`l'.QCB=$VQ $X), indicators($cmp_cont $cmp_probit $cmp_cont $cmp_cont) ro cl(cid) iterate(70) 
  est store d`y'`l'
  qui test ([L`l'SCB]L`l'.ivSCB [L`l'QCB]L`l'.ivQCB)
  mat D`y'[3,`l']=r(chi2)

  drop meanIMF lnunder ivIMF meanSCB meanQCB ivSCB ivQCB
  } 
}

  ** Table B5 ** 
  esttab dvdem_corr*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMFnn *SCB *QCB)
  mat li Dvdem_corr
  
  ** Table B6 **
  esttab dvdem_execorr*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMFnn *SCB *QCB)
  mat li Dvdem_execorr
  
  ** Table B15 **
  esttab dicc_WGI*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMFnn *SCB *QCB)
  mat li Dicc_WGI
  
  ** Table B16 **
  esttab sti_cpi*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMFnn *SCB *QCB)
  mat li Dti_cpi

  * Note that all results from all models are accessible by uncommenting the following code...
  * foreach y in icrgPC vdem_corr vdem_execorr ti_cpi icc_WGI{
  *   esttab fe`y'*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMF* *SCB* *QCB*)
  *   esttab s`y'*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMF* *SCB* *QCB*)  
  *   esttab d`y'*, starlevels(* .1  ** .05  *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(*IMF* *SCB* *QCB*)
  *   mat li D`y'
  * }

  
* Table B7: ECMs

 foreach ctrl in gdppc_WDI pwt p_durable p_polity2 pop_urb gxp_gdp min_gdp oilpc{
    g d`ctrl'=d.`ctrl'
    }
  g lndgdppc=ln(1+dgdppc_WDI)
  replace lndgdppc=-ln(1-dgdppc_WDI) if dgdppc_WDI<0
  g lndoilpc=ln(doilpc+1)
  replace lndoilpc=-ln(1-doilpc) if doilpc<0

  global LBMAmin  L.lngdppc L.pwt_hci_QOG L.p_durable_QOG L.p_polity2_QOG L.pop_urb_tot_WDI L.gxp_gdp_WDI L.min_gdp_WDI L.lnoilpc
  global DBMAmin  lndgdppc dpwt dp_durable dp_polity2 dpop_urb dgxp_gdp dmin_gdp lndoilpc 
  
  global LBMAmax  L.lngdppc L.p_durable L.p_polity2 L.pop_urb L.min_gdp L.lnoilpc
  global dBMAmax  lndgdppc dp_durable dp_polity dpop_urb dmin_gdp lndoilpc 
  
  global ECM $LBMAmax $dBMAmax

  mat r2ECM=J(4,2,0)
  local t=1
  
foreach y in icrgPC vdem_corr {
  
  di "outcome `y' with 1) LDV in Eq_{SCB}, 2) no IV for QCB"

  qui xtreg d.`y' d.SCB l.SCB d.QCB l.QCB d.IMFnn l.IMFnn l.`y' $ECM _Iyear*, fe cl(cid)
  est store e1fe`y'
  mat r2ECM[1,`t']=e(N)
  mat r2ECM[2,`t']=e(r2_w)

  qui egen meanIMF=mean(IMFnn), by(cid)
  g lnunder=ln(1+nUnder)
  qui g ivIMF=lnunder*meanIMF
  global Z l.ivIMF l.lnunder l.meanIMF _Icid* _Iyear* 
  global Z0 L2.IMFcum L2.s_unga3g7 L2.nUnder L2.lngdppc L2.p_polity2_QOG L2.reserves L2.gdp_growth_WDI L2.debtser_gni L2.dpi_exelec _Iregid* _Iyear*

  qui cmp (d.`y'=d.SCB l.SCB d.QCB l.QCB d.IMFnn l.IMFnn l.`y' $ECM _Icid* l.year) (l.IMFnn=$Z0), indicators($cmp_cont $cmp_probit) ro cl(cid) iterate(40)
  est store e1s`y'
  qui probit l.IMFnn $Z0 
  mat r2ECM[3,`t']=e(r2_p)

  qui egen meanSCB=mean(SCB), by(cid)
  qui egen meanQCB=mean(QCB), by(cid)
  qui g ivSCB=meanSCB*lnunder
  qui g ivQCB=meanQCB*lnunder 
  global VS l.ivSCB l.lnunder l.meanSCB $ECM _Icid* _Iyear*  
  global VQ l.ivQCB l.lnunder l.meanQCB $ECM _Icid* _Iyear* 
  
  qui cmp (d.`y'=d.SCB l.SCB d.QCB l.QCB d.IMFnn l.IMFnn l.`y' $ECM _Icid* l.year) (l.IMFnn=$Z0) (lSCB: l.SCB=$VS l.`y'), indicators($cmp_cont $cmp_probit $cmp_cont) ro cl(cid) iterate(60) 
  est store e1d`y'
  qui test [lSCB]l.ivSCB
  mat r2ECM[4,`t']=r(chi2)
  
  drop meanIMF lnunder ivIMF meanSCB meanQCB ivSCB ivQCB
  local t=`t'+1
  }

  ** Table B7 **
  esttab e1dicrgPC e1dvdem_corr, starlevels(* .1  ** .05  *** .01) cells((b(star fmt(3)) se(par fmt(3)))) keep(*IMF* *SCB* *QCB* *icrg* *vdem*)  
  mat li r2ECM  
  
  
* Table B8: Plain FE

  mat LNO=J(6,5,0)
  mat LNO2=LNO
  mat LNODiag=J(3,5,0)

forvalues l=1/5{
  
  local k=`l'+1
  di "ICRG index, lag=`l'"
  
  global X L`l'.lngdppc L`l'.pwt_hci L`l'.p_durable_QOG L`l'.p_polity2_QOG  L`l'.pop_urb_tot_WDI L`l'.min_gdp_WDI L`l'.lnoilpc
  global Z L`k'.IMFcum L`k'.s_unga3g7 L`k'.nUnder L`k'.lngdppc L`k'.p_polity2_QOG L`k'.reserves L`k'.gdp_growth_WDI L`k'.debtser_gni L`k'.dpi_exelec _Iregid* _Iyear*
  
  qui cmp (icrgPC =L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Icid* _Iyear*) (L`l'.IMFnn=$Z), indicators($cmp_cont $cmp_probit) ro cl(cid) iterate(50)
  est store r0_sqeff`l'
  mat B=e(b)
  mat S=e(V)
  mat LNO2[1,`l']=B[1,1]
  mat LNO2[2,`l']=sqrt(S[1,1])
  mat LNO2[3,`l']=B[1,2]
  mat LNO2[4,`l']=sqrt(S[2,2])
  mat LNO2[5,`l']=B[1,3]
  mat LNO2[6,`l']=sqrt(S[3,3])
  
  qui xtreg icrgPC L`l'.SCB L`l'.QCB L`l'.IMFnn $X _Iyear* if e(sample), fe cl(cid)
  est store r1_sqeff`l'
  mat B=e(b)
  mat S=e(V)
  mat LNO[1,`l']=B[1,1]
  mat LNO[2,`l']=sqrt(S[1,1])
  mat LNO[3,`l']=B[1,2]
  mat LNO[4,`l']=sqrt(S[2,2])
  mat LNO[5,`l']=B[1,3]
  mat LNO[6,`l']=sqrt(S[3,3])
  mat LNODiag[2,`l']=e(r2_w)	
  mat LNODiag[1,`l']=e(N)	
  qui probit L`l'.IMFnn $Z
  mat LNODiag[3,`l']=e(r2_p)
  }
  
  ** Table B8 **
  mat li LNO
  mat li LNODiag  
  
  
* Table B9: Accounting for program selection   
  
  ** Table B9 **
  mat li LNO2
  mat li LNODiag
  
  
* Correlations
  
  ** Table B12 **
  corr icrgPC IMFnn SCB QCB $BMAmin 
  
  
***********************************************************************  
* BEEPS analysis - supplemental appendix
***********************************************************************

* Data

  use "Replication_BEEPS.dta", clear 
  
  rename time timeOLD
  gen timeID=timeOLD+1
  lab var timeID "One-period lagged variables - timeID"
  tab timeID
  drop if timeID<=7
  drop if incid==1
  sort iso3 timeID

  merge iso3 timeID using "BEEPS_20160728.dta"
  tab _merge
  sort cid timeID
  xtset cid timeID

  order cid iso3 timeID 
  g lngdppc=ln(gdppc_WDI)
  g lnpop=ln(unna_pop)
  g lnoilpc=ln(1+(1E+6)*ross_oil_prod/unna_pop)
  rename transparency HRV_index
  replace dy_colGBR=ceil(dy_colGBR)

  gen NonMiss=(br_inc!=.)
  egen N=sum(NonMiss), by(cid)
  drop NonMiss 
  
  
* Descriptive statistics 

  estpost summarize br_inc br_int gft_tax imf1 SCB QCB lngdppc p_polity2_QOG p_durable_QOG lnoilpc min_gdp_WDI  age dom_gov for_prv inp_foreign0 inp_foreign  days_exp days_imp comp_pct  if N>1 
  
  ** Table A2 -- BEEPS **
  esttab, cells("count mean sd min max") noobs replace label   
  
  set matsize 800
  cmp setup
  qui xi:reg br_inc i.cid i.timeID
  
  global X lngdppc p_polity2_QOG p_durable_QOG lnoilpc min_gdp_WDI
  global Firm age dom_gov for_prv inp_foreign0 inp_foreign
  global FirmEnd days_exp days_imp comp_pct 
  
  mat Mbr_inc=J(3,9,0)
  mat Mbr_int=Mbr_inc
  mat Mgft_tax=Mbr_inc  
  
  
* Additional analyses

  qui xtreg br_inc SCB QCB imf1 i.timeID if N>1, fe
  g samp=(e(sample))
  tab iso3 if samp
  
foreach y in  br_int gft_tax{
  qui xtreg `y' SCB QCB imf1 i.timeID if N>1 & samp, fe cl(cid) 
  est store fe1`y'
  mat M`y'[1,1]=e(N)
  mat M`y'[2,1]=e(r2_w)
 
  qui xtreg `y' SCB QCB imf1 $X i.timeID if N>1 & samp, fe cl(cid) 
  est store fe2`y'
  mat M`y'[1,2]=e(N)
  mat M`y'[2,2]=e(r2_w)
 
  qui xtreg `y' SCB QCB imf1 $X $Firm i.timeID if N>1 & samp, fe cl(cid) 
  est store fe3`y'
  mat M`y'[1,3]=e(N)
  mat M`y'[2,3]=e(r2_w)
  }

foreach y in  br_int gft_tax {
  di "Outcome: `y'"
  qui treatreg `y' SCB QCB imf1 i.cid i.timeID if N>1 & samp , treat(imf1=limf1 nUnder s_unga3g7 gdp_growth_lag i.regid i.timeID) twostep hazard(imr)
  qui xtreg `y' SCB QCB imf1 imr _Icid* _ItimeID* if samp , fe cl(cid)
  est store he1`y'
  mat M`y'[1,4]=e(N)
  mat M`y'[2,4]=e(r2_w)
  qui cmp (`y'= SCB QCB imf1 imr _Icid* _ItimeID*) (SCB=lSCB _Itime*) (QCB=lQCB _Itime*) if N>1, indicators(samp $cmp_cont $cmp_cont) ro cl(cid)
  est store iv1`y'
  mat M`y'[1,7]=e(N1)
  mat M`y'[2,7]=M`y'[2,4]
  qui test ([SCB]lSCB [QCB]lQCB)
  mat M`y'[3,7]=r(chi2)
  drop imr
  
  qui treatreg `y' SCB QCB imf1 $X i.cid i.timeID if N>1 & samp , treat(imf1=limf1 nUnder s_unga3g7 gdp_growth_lag $X i.regid i.timeID) twostep hazard(imr)
  qui xtreg `y' SCB QCB imf1 imr $X _Icid* _ItimeID* if samp , fe cl(cid)
  est store he2`y'
  mat M`y'[1,5]=e(N)
  mat M`y'[2,5]=e(r2_w)
  qui cmp (`y'= SCB QCB imf1 imr $X _Icid* _ItimeID*) (SCB=lSCB $X _Itime*) (QCB=lQCB $X _Itime*) if N>1, indicators(samp $cmp_cont $cmp_cont) ro cl(cid)
  est store iv2`y'
  mat M`y'[1,8]=e(N1)
  mat M`y'[2,8]=M`y'[2,5] 
  qui test ([SCB]lSCB [QCB]lQCB)
  mat M`y'[3,8]=r(chi2)
  drop imr
  
  qui treatreg `y' SCB QCB imf1 $X $Firm i.cid i.timeID if N>1 & samp , treat(imf1=limf1 nUnder s_unga3g7 gdp_growth_lag $X $Firm i.regid i.timeID) twostep hazard(imr)
  qui xtreg `y' SCB QCB imf1 imr _Icid* $X $Firm _ItimeID* if samp , fe cl(cid)
  est store he3`y'
  mat M`y'[1,6]=e(N)
  mat M`y'[2,6]=e(r2_w)  
  qui cmp (`y'= SCB QCB imf1 imr $X $Firm _Icid* _ItimeID*) (SCB=lSCB $X $Firm _Itime*) (QCB=lQCB $X $Firm _Itime*) if N>1, indicators(samp $cmp_cont $cmp_cont) ro cl(cid)
  est store iv3`y'
  mat M`y'[1,9]=e(N1)
  mat M`y'[2,9]=M`y'[2,6] 
  qui test ([SCB]lSCB [QCB]lQCB)
  mat M`y'[3,9]=r(chi2)
  drop imr
  }

  ** Table B10 **
  esttab fe*br_int he*br_int iv*br_int, cells(b(star fmt(3)) se(par fmt(3))) keep(imf1 *SC* *QC* $X imr $Firm) order(*SC* *QC* imf1 $X imr $Firm imr)   
  di "Diagnostics:"
  mat li Mbr_int
  
  ** Table B11 **
  esttab fe*gft_tax he*gft_tax iv*gft_tax, cells(b(star fmt(3)) se(par fmt(3))) keep(imf1 *SC* *QC* $X imr $Firm) order(*SC* *QC* imf1 $X imr $Firm imr)   
  di "Diagnostics:"
  mat li Mgft_tax
  
  
* Correlations
  
  ** Table B13 **
  corr gft_tax br_int IMFnn SCB QCB $X $Firm
  
  * Table B14 see Replication_ICVS
